
#include "arduino.h"

char action;
char room;
char onoff;
char buf[100];
	int i;


void save_action(char input_action){
	switch (input_action){
		case '0': action = '0'; break; // review
		case '1': action= '1' ; break; //change
	
	default : action = 'N'; break; // anything else
	

}
	}

	
	
	void save_room(char input_room){
	switch (input_room){
		case 'A': room = 'A'; break; // room A
		case 'B': room= 'B' ; break; // room B
		case 'C': room = 'C'; break; // room C
		case 'D': room= 'D' ; break; //room D
	  case 'E': room = 'E'; break; // room E
		case 'F': room= 'F' ; break; // room F
		case 'G': room = 'G'; break; // room G
		case 'H': room= 'H' ; break; // room H
	default : room = 'N'; break; // anything else
	

}
	}
	

	
	
void save_onoff(char input_onoff){
	switch (input_onoff){
		case '0': onoff = '0'; break; // review
		case '1': onoff= '1' ; break; //change
	
	default : onoff = 'N'; break; // anything else
	

}
	}	
	
char get_action(){
return action;
}

char get_room(){
return room;
}


char get_onoff(){
return onoff;
}
/**
* @brief	The bluetooth_rx_tx_command() function decodes input serial data from Bluetooth and changes extern variables action, onoff, room
* @param	None
* @retval	None
*/
void bluetooth_rx_tx_command()
{
	
		if (Serial.available()) {
		i = 0;
		do {
			buf[i++] = Serial.read();
		} while(Serial.available());
		buf[i] = 0;
		save_action(buf[0]); 
		save_room(buf[1]);
		save_onoff(buf[2]);
		action = get_action();
		room= get_room();
		onoff= get_onoff();
		
		Serial.println(&action); 
		Serial.println(&room); 
		Serial.println(&onoff);   
		
		
		
		
	} else {
		Serial.println("Please enter the command");
	}
}
